@extends('app')

@section('content')
<link href="{{ asset('/css/spinners.css') }}" rel="stylesheet">
<div id="grid" class="grid" style="position: fixed;z-index: 1000;left:50%;display: none;">
    <div class="cell">
        <div class="card">
            <span class="throbber-loader">Loading…</span>
        </div>
    </div>
</div>
<div class="loading" style=" font-size:20px;text-align:center;display:none;">
    <i class="icon-spinner icon-spin orange bigger-125"></i>
</div>
<ul class="nav nav-tabs">
    <li class="active"><a href="{{ url('/admin/enterprise/companys')}}">信息列表</a></li>
    <li><a href="{{ url('/admin/enterprise/companys/create') }}">信息添加</a></li>
</ul>

<div class="panel panel-info mt20">
    <div class="panel-heading">筛选</div>
    <div class="panel-body">
        <form action="" method="get" class="form-horizontal" role="form" id="form1">
            <div class="input-group">
                <div class="input-group-addon">企业名称</div>
                <input class="form-control" name="title" type="text" value="{{$title}}" placeholder="企业名称">
                <div class="input-group-addon">企业用户</div>
                <input class="form-control" name="username" type="text" value="{{$username}}" placeholder="作者名称">
                <div class="input-group-addon">行业</div>
                <select name="type" class="form-control">
                    <option value="0">不限</option>
                    @foreach($types as $tp)
                    <option value="{{$tp->id}}" @if( $nowtype == $tp->id) selected @endif>{{$tp->name}}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group mt10">
                <div class="col-md-1 col-xs-12">
                    <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                   
                </div>
                <div class="col-md-1 col-xs-12">
                   <div style="padding-left:15px;">
                        <form id="exportform" enctype="multipart/form-data" method="post">
                          <div class="form-group">
                            <input type="file" name="report" id="uploadfile">
            
                          </div>
                        </form>
                    </div>
                 </div>
            </div>
        </form>
    </div>
</div>
<div class="panel panel-default mt20">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
          <thead>
            <tr>
              <th>编号</th>
              <th>企业名称</th>
              <th>企业邮箱</th>
              <th>企业规模</th>
              <th>审核状态</th>
              <th>充电加油</th>
              <th>加入时间</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
          @foreach($company as $res)
            <tr id="news_{{ $res->id }}">
              <td>{{ $res->id }}</td>
              <td><a href="{{ url('/admin/enterprise/companys/'.$res->id) }}">{{ str_limit($res->name,30) }} </a></td>
              <td>{{ $res->email }}</td>
              <td>{{ $res->scales->name?:'' }}</td>
              <td>
                @if($res->is_validate == 1)
                    <span class="label label-success arrowed">
                        已审核通过
                    </span>
                @elseif($res->is_validate == 2)
                    <span class="label label-danger arrowed-in">审核不通过</span>
                @else
                    <span class="label label-warning" onclick="companyModel('admin/enterprise/companys',{{ $res->id }})">
    					<i class="icon-warning-sign bigger-120"></i>
    					未审核
    				</span>
                @endif
              </td>
              <td id="disabled">
                @if($res->is_teaches == 1)
                 <span class="glyphicon glyphicon-ok-circle  green-remove"
                    onclick="changeUserStatus('/admin/enterprise/companys/teachesed','{{ $res->id }}', '{{ $res->is_teaches }}', '{{ csrf_token() }}')"></span>
                @else
                <span class="glyphicon glyphicon-remove-circle red-ok"
                          onclick="changeUserStatus('/admin/enterprise/companys/teachesed','{{ $res->id }}', '{{ $res->is_teaches }}', '{{ csrf_token() }}')"></span>
                @endif
              </td>
              <td>{{ date('Y-m-d',strtotime($res->created_at))}}</td>
              <td>
                <a href="{{ url('/admin/enterprise/companys/'.$res->id) }}"><i class="glyphicon glyphicon-edit"></i></a>
                <a href="javascript:void(0);" onclick="delete_one('/admin/enterprise/companys/{{$res->id}}','{{$res->id}}','{{ csrf_token() }}')"><i class="glyphicon glyphicon-remove-sign"></i></a>
              </td>
            </tr>
          @endforeach
          </tbody>
        </table>
    </div>
</div>
<div>{!! $company->render() !!} </div>
<div class="modal fade bs-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">文章审核</h4>
      </div>
      <div class="modal-body">
            <form id='validated'>
                <table class="table table-striped" id="showinfos">
                </table>
            </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-info" id="submittags" data-dismiss="modal" onclick="to_validate('/admin/enterprise/companys/validated','{{ csrf_token() }}')">确定</button>
        <button type="button" class="btn" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
       $(function(){
        /***图片上传****/
        $("#uploadfile").uploadify({
            'formData'     : {
                'app':'company',
                'fileField':'upfile',
                '_token':'{{ csrf_token() }}'
            },
            "width"           : 120,
            "height"          : 30,
            "queueSizeLimit"  :1,
            "swf"             : "{{ asset('/js/uploadify/uploadify.swf') }}",
            "fileObjName"     : "upfile",
            "buttonText"      : "导入Excel",
            "uploader"        : '/admin/enterprise/companys/import',
            'removeTimeout'   : 1,
            'fileTypeExts'    : '*.jpg; *.png; *.gif;*.xlsx',
            'onSelect'        : function(){
                 $('.loading').css({'display': 'block'});
            },
            'onUploadSuccess':function(file, data, response){
                var data = eval('(' + data + ')');
                if(data.status == 'success'){
	                $('.loading').html(data.msg);
	                history.go(0);
                }else{
                	$('.loading').html(data.msg);
                	BootstrapDialog.alert({title:'错误提示',message:data.msg});
                }
            }
        });
    });
</script>
@endsection
